import { Injectable } from '@angular/core';
import { RequestService } from '../../../cores/services/request.service';
import { ApiData } from '../../../cores/classes/api-data.class';
import { SearchParams } from '../../../cores/classes/search-params';
import { PlatformManager } from '../interfaces/platform.interfaces';
import { Price, Closed } from './../interfaces/inventory.interfaces';
import { Observable } from 'rxjs';
import { Pagination } from 'ng-tui';

@Injectable()
export class AccountService {

    constructor(private request: RequestService) { }

    /**
  * 余额列表
  */
    surpluslist(pagination: Pagination, search: SearchParams): Observable<ApiData> {
        return this.request.get('/managerapi/early/stage/account/surplus/search', pagination.getpageDataWith(search.values));
    }
    /**
   * 添加余额
   *
   */
    surplusadd(price: Price): Observable<ApiData> {
        return this.request.post('/managerapi/early/stage/account/surplus/add', price);
    }
    /**
    * 编辑余额
    *
    */
    updatesurplus(price: Price): Observable<ApiData> {
        return this.request.put('/managerapi/early/stage/account/surplus/update', price);
    }
    /**
   * 删除余额
   *
   */
    deleltsurplurs(id: number): Observable<ApiData> {
        return this.request.delete('/managerapi/early/stage/account/surplus/delete', { id });
    }
    /**
     * 应收列表
     */
    receivablelist(pagination: Pagination, search: SearchParams): Observable<ApiData> {
        return this.request.get('/managerapi/early/stage/receivable/search', pagination.getpageDataWith(search.values));
    }
    /**
        * 添加应收
        *
        */
    receivableadd(closed: Closed): Observable<ApiData> {
        return this.request.post('/managerapi/early/stage/receivable/add', closed);
    }
    /**
    * 编辑应收
    *
    */
    updatereceivable(closed: Closed): Observable<ApiData> {
        return this.request.put('/managerapi/early/stage/receivable/update', closed);
    }
     /**
   * 删除应收
   *
   */
  deleltreceivable(id: number): Observable<ApiData> {
    return this.request.delete('/managerapi/early/stage/receivable/delete', { id });
}


 /**
     * 应付列表
     */
    paymentlist(pagination: Pagination, search: SearchParams): Observable<ApiData> {
        return this.request.get('/managerapi/early/stage/payment/search', pagination.getpageDataWith(search.values));
    }
    /**
   * 删除应付
   *
   */
  delelpayment(id: number): Observable<ApiData> {
    return this.request.delete('/managerapi/early/stage/payment/delete', { id });
}
}
